<template>
<el-dialog :append-to-body="true" class="add-dialog" :title="editForm.title" :visible.sync="editForm.show" width="500px" :close-on-click-modal="false">
    <el-form ref="ruleForm" :model="editForm.form" :rules="rules" label-width="100px" @submit.native.prevent>
        <el-form-item label="模型名称" prop="modelName">
            <el-input :maxlength="48" clearable placeholder="请输入实验名称" v-model="editForm.form.modelName"></el-input>
        </el-form-item>
        <el-form-item label="模型描述">
            <el-input :maxlength="100" type="textarea" :rows="5" clearable placeholder="请输入模型描述" v-model="editForm.form.description"></el-input>
        </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="editForm.show=false">取 消</el-button>
      <el-button type="primary" v-preventReClick="2000" @click="handleSave">确 定</el-button>
    </span>
</el-dialog>
</template>

<script>
export default {
    name: 'AddDialog',
    props: {
        editForm: {
            type: Object,
            required: true
        }
    },
    data () {
        return {
            rules: {
                modelName: [
                    { required: true, message: '请输入模型名称', trigger: 'blur' }
                ]
            }
        }
    },
    methods: {
        handleSave () {
            this.$refs['ruleForm'].validate((valid) => {
                if (valid) {
                    this.$emit('save')
                } else {
                    return false
                }
            })
        }
    }
}
</script>
